<template>
	<view class="wrap ">
		<!-- <js-lang title="home.title" :showBtn="true"></js-lang> -->
		<!-- <u-swiper :height="0" :list="imgList" :title="false" @click="imgListClick"></u-swiper> -->
		<view v-for="res in menuList1" :key="res.menuCode">
			<view class="cu-bar bg-white solid-bottom">
				<view class="action ">
					<u-icon name="/static/image/zfgs/index/icon@2x(6).png" size="80"></u-icon>
					<text class="text-lg  text-bold " style="font-size: 42rpx;">{{res.menuName}}</text>
				</view>
			</view>
			<view class="flex margin-sm flex-wrap justify-between u-skeleton">
				<!-- margin-bottom -->
				<view class="flex bg-white padding radius " v-for="item in res.childList"
					:key="item.menuName" @click="navTo(item.url)" style="margin-bottom: 15rpx;">
					<!-- v-if="item.isSHow" -->
					<view class="xm-item u-skeleton-rect">
						<view class="xm-item-1">{{item.menuName}}</view>
						<view class="xm-item-2">{{item.menuTitle}}</view>
					</view>
					<image style="width: 86rpx; height: 86rpx" :src="item.menuIcon" mode="aspectFit"
						class="u-skeleton-circle" />
				</view>
				<!-- <u-skeleton :loading="loading" :animation="true" bgColor="#FFF"></u-skeleton> -->
			</view>
		</view>
		

	</view>
</template>

<script>
	import checkVersion from "@/pages/lq-upgrade/checkVersion.js";
	export default {
		data() {
			return {
				stringPermissions: [],
				imgList: [],
				todoCount: 0,
				menuList1: [],
				menuList: [
					// 发货
					{
						extend:{
							extendS2:'menue:zhuangche:fahuo'
						},
						menuIcon: '/static/image/zfgs/index/icon21.png',
						url: '/pages/mf/fh/fh',
					},
					// 到货
					{
						extend:{
							extendS2:'menue:zhuangche:daohuo'
						},
						menuIcon: '/static/image/zfgs/index/jcqr.png',
						url: '/pages/mf/dh/dh',
					},
					// 到货单装
					{
						extend:{
							extendS2:'menue:zhuangche:dhdz'
						},
						menuIcon: '/static/image/zfgs/index/clcx.png',
						url: '/pages/mf/dh/dzList',
					},
					// 到货混装
					{
						extend:{
							extendS2:'menue:zhuangche:dhhz'
						},
						menuIcon: '/static/image/zfgs/index/gcrz.png',
						url: '/pages/mf/dh/hzList',
					},
					// 发货单装
					{
						extend:{
							extendS2:'menue:zhuangche:fhdz'
						},
						menuIcon: '/static/image/zfgs/index/icon@2x(12).png',
						url: '/pages/mf/fh/dzList',
					},
					// 发货混装
					{
						extend:{
							extendS2:'menue:zhuangche:fhhz'
						},
						menuIcon: '/static/image/zfgs/index/tstbz.png',
						url: '/pages/mf/fh/hzList',
					},
					// 废旧物资
					{
						extend:{
							extendS2:'menue:zhuangche:fjwz'
						},
						menuIcon: '/static/image/zfgs/index/gb.png',
						url: '/pages/mf/fjwz/index',
					},
					// 采购入库
					{
						extend:{
							extendS2:'menue:rkzy:cgrk'
						},
						menuIcon: '/static/image/zfgs/index/bzrz.png',
						url: '/pages/mf/cgrk/list',
					},
					{
						extend:{
							extendS2:'menue:rkzy:llsq'
						},
						menuIcon: '/static/image/zfgs/index/jcqr.png',
						url: '/pages/mf/llsq/list',
					},
					{
						extend:{
							extendS2:'menue:rkzy:cprk'
						},
						menuIcon: '/static/image/zfgs/index/icon@2x(10).png',
						url: '/pages/mf/cprk/list',
					},
					{
						extend:{
							extendS2:'menue:xsfh:zc'
						},
						menuIcon: '/static/image/zfgs/index/icon@2x(10).png',
						url: '/pages/mf/zc/dzList',
					},
					{
						extend:{
							extendS2:'menue:bqdy:bqdy'
						},
						menuIcon: '/static/image/zfgs/index/icon@2x(10).png',
						url: '/pagesData/print/list',
					},
				],
			}
		},
		onShow() {
		},
		created() {
			 
		},
		onLoad() {
			this.upgrade();
			var _this = this;
			console.log(this,'$myMethod')
			this.$u.api.menuTree().then(res => {
				if (res.length > 0) {
					res.forEach(item => {
						if ('移动端管理' == item.menuName) {
							item.childList.forEach(item2 => {
								if ('APP菜单' == item2.menuName) {
									this.showMenu(item2.childList);
								}
							})

						}
					})

				}
			});
			// this.$u.api.authInfo().then(res => {
			// 	this.stringPermissions=(res==null || res.stringPermissions==null)?[]:res.stringPermissions;
			// });
		},
		methods: {
			//检查版本更新
			upgrade() {
			  // #ifdef APP-PLUS
			  this.$u.api.upgradeCheck().then((res) => {
			    let url = res.data.apkUrl
			      ? res.data.apkUrl
			      : this.vuex_config.xtUrl + res.data.xtUrl;
			    if (res.result == "true") {
			      checkVersion({
			        name: res.data.upTitle, //最新版本名称
			        code: res.data.upVersion, //最新版本号
			        content: `${res.data.upContent}`, //更新内容
			        url, //下载链接
			        // forceUpdate: true, //是否强制升级
			        forceUpdate: res.data.upType == '3'?true:false, //是否强制升级
			      });
			    }
			  });
			  // #endif
			},
			//显示菜单
			showMenu(list) {
				this.menuList1 = list
				this.menuList.forEach(item => {
					this.menuList1.forEach(res => {
						res.childList.forEach(req => {
							if (req.extend?.extendS2 == item.extend?.extendS2 ) {
								req.menuIcon = item.menuIcon;
								req.url = item.url;
							}
						})

					})
				})

				console.log(this.menuList1, 'this.menuList1===');
			},
			navTo(url) {
				// uni.navigateTo({
				// 	url: url
				// });
				if(url == '/pagesData/print/list'){
					let url = 'list'
					// #ifdef MP
						url = 'wxlist'
					// #endif
					
					// #ifdef APP-PLUS
						url = 'list'
					// #endif
					
					uni.navigateTo({
					  url: '/pagesData/print/'+url,
					});
					
				}else{
					uni.navigateTo({
						url: url
					});
				}
			},
			imgListClick(index) {
				console.log(`点击了第${index + 1}页图片`)
			},
			itemClick(index) {
				console.log(index);
			}
		}
	}
</script>

<style scoped lang="scss">
	.cu-item {
		width: 41% !important;
		height: 90px;
	}

	.cuIcon-cardboardfill {
		margin-top: 20px !important;
	}

	.xm-title {
		border-radius: 20rpx;
		font-size: 36rpx;
		background-color: #fff;
		// background-image: url("/static/image/zfgs/index/icon@2x.png");
		// background-repeat: no-repeat;
		// background-size: 38rpx 42rpx;
		// background-position: 10rpx 10rpx;
		position: relative;

		.xm-title-p1 {
			color: #999999;
			font-size: 36rpx;
			line-height: 40rpx;
			margin-bottom: 8rpx;
		}

		.xm-title-p2 {
			color: #3d3d3d;
			line-height: 48rpx;
		}

		.xm-title-img {
			width: 38rpx;
			height: 42rpx;
			position: absolute;
			top: 0;
			right: 32rpx;
		}
	}

	.xm-item-1 {
		font-size: 42rpx;
		color: #3d3d3d;
		line-height: 40rpx;
		position: relative;
		margin-bottom: 26rpx;
	}

	.xm-item-1::after {
		content: "";
		display: inline-block;
		position: absolute;
		width: 32rpx;
		height: 4rpx;
		background-color: #bbbbbb;
		bottom: -16rpx;
		left: 0;
	}

	.xm-item {
		width: 200rpx;
	}

	.radius {
		border-radius: 20rpx;
	}

	.xm-item-2 {
		font-size: 34rpx;
		color: #999999;
	}
</style>